package com.clear.composite;

import java.util.LinkedList;
import java.util.List;

/**
 * Composite（组合节点）
 */
public class Folder implements FileSystem{
    private String name;
    private List<FileSystem> children;

    public Folder(String name) {
        this.name = name;
        this.children = new LinkedList<>();
    }

    public void add(FileSystem fileSystem) {
        children.add(fileSystem);
    }

    public void remove(FileSystem fileSystem) {
        children.remove(fileSystem);
    }

    @Override
    public void display() {
        System.out.println("Folder: " + name);
        for (FileSystem fileSystem : children) {
            fileSystem.display();
        }
    }
}
